From 361117416a3dcf457571af661e09e37f5722ce9c Mon Sep 17 00:00:00 2001 From: robertl Date: Tue, 2 Dec 2003 15:12:26 +0000 Subject: [PATCH] Add secondary basemap upload. From Bernhard Nebel. --- magxfer/Makefile | 4 ++-- magxfer/README | 6 ++++- magxfer/magxfer.c | 57 ++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 56 insertions(+), 11 deletions(-) diff --git a/magxfer/Makefile b/magxfer/Makefile index 5db1ecde9..1507d9d6a 100644 --- a/magxfer/Makefile +++ b/magxfer/Makefile @@ -5,8 +5,8 @@ magxfer: magxfer.c clean: rm -f magxfer -VERSIONU=1_0_0 -VERSIOND=1.0.0 +VERSIONU=1_0_1 +VERSIOND=1.0.1 release: cvs tag magxfer_$(VERSIONU) cvs export -r magxfer_$(VERSIONU) -d magxfer-$(VERSIOND) magxfer diff --git a/magxfer/README b/magxfer/README index 1fccd2fa8..b72860745 100644 --- a/magxfer/README +++ b/magxfer/README @@ -11,7 +11,7 @@ utility to shoot them into your receiver. The files you need are in the Usage is simple: - magxfer [-p portname] [-b bitrate] -f filetosend.img + magxfer [-p portname] [-b bitrate] [-t type ] -f filetosend.img portname specifies the serial port to use. The default is "/dev/ttyS0" which is the first serial port on a @@ -21,6 +21,10 @@ Usage is simple: default is 4800. After connection is made, the actual transfer happens at 115200 bps, regardless of this option. + type can be d for detailed map or s for secondary base map such + as by Worldwide Basemap or p for primary basemap. Default + is d. + filetosend.img is the image file you wish to upload to the unit. diff --git a/magxfer/magxfer.c b/magxfer/magxfer.c index 4cef3981c..12991958d 100644 --- a/magxfer/magxfer.c +++ b/magxfer/magxfer.c @@ -41,6 +41,22 @@ typedef struct { void dump_xframe(vld *frame); void send_terminate(void); +const char *usagestring = "\ +Usage: magxfer [-p portname] [-b bitrate] [-t type ] -f filetosend.img\n\ + portname port for uplkoad (default /dev/ttyS0)\n\ + bitrate bitrate (default is 4800)\n\ + type can be \n\ + b (secondary base map),\n\ + B (primary base map), or\n\ + d (detailed map)\n\ + (default d)\n\ + filetosend.img is the image file you wish to upload to the unit\n"; +void +usage() +{ + fprintf(stderr,"%s",usagestring); +} + void debug(const char *fmt, ...) { @@ -443,10 +459,14 @@ setup_port(const char *portname, unsigned bitrate) * the data. */ void -send_upload_cmd(void) +send_upload_cmd(unsigned detailed) { -#define MU_CMD "$PMGNCMD,MPUPLOAD,2*72\r\n" - write(magfd, MU_CMD, sizeof(MU_CMD)); + static const char *cmd[] = { + "$PMGNCMD,MPUPLOAD,1*71\r\n", + "$PMGNCMD,MPUPLOAD,2*72\r\n", + "$PMGNCMD,MPUPLOAD,3*73\r\n", + }; + write(magfd, cmd[detailed], strlen(cmd[detailed] + 1)); cfsetospeed(&new_tio, B115200); cfsetispeed(&new_tio, B115200); tcsetattr(magfd, TCSADRAIN, &new_tio); @@ -506,18 +526,32 @@ sync_receiver(void) int main(int argc, char *argv[]) { - static char ibuf[10000000]; + static char ibuf[64*1024*1024]; unsigned short cksum; size_t file_sz; size_t sent_sz; FILE *inf; int c; unsigned bitrate = 4800; + int detailedmap = 1; const char *portname = "/dev/ttyS0"; - const char *ifilename = "/dev/ttyS0"; + const char *ifilename = ""; + - while ((c = getopt(argc, argv, "f:p:b:D:")) != EOF) { + while ((c = getopt(argc, argv, "t:f:p:b:D:")) != EOF) { switch(c) { + case 't': + if (strcmp(optarg,"s") == 0) + detailedmap = 2; + else if (strcmp(optarg,"d") == 0) + detailedmap = 1; + else if (strcmp(optarg,"p") == 0) + detailedmap = 0; + else { + fprintf(stderr,"Map type (-t option) can only be 'd', 'p', or 's'\n"); + exit(1); + } + break; case 'p': portname = optarg; break; @@ -531,11 +565,18 @@ main(int argc, char *argv[]) bitrate = atoi(optarg); break; default: + usage(); + exit(1); break; } } + if (ifilename[0] == '\0') { + fprintf(stderr, "No input file specified. Exiting.\n"); + usage(); + exit(1); + } setup_port(portname, bitrate); - send_upload_cmd(); + send_upload_cmd(detailedmap); sync_receiver(); inf = fopen(ifilename, "r"); @@ -543,7 +584,7 @@ main(int argc, char *argv[]) if (file_sz == sizeof(ibuf)) { fprintf(stderr, "File '%s' bigger than %d bytes. Exiting.\n", ifilename, sizeof(ibuf)); - + exit(1); } cksum = xor_checksum(ibuf, file_sz); -- 2.30.2